//
//  ViewModelType.swift
//  sdxf
//
//  Created by 湛亚磊 on 2020/1/13.
//  Copyright © 2020 湛亚磊. All rights reserved.
//

import UIKit
///需要手动调用一次transform
public protocol ViewModelType {
    associatedtype Input
    associatedtype Output
    func transform(input: Input) -> Output
}
///直接分开调用input和output
public protocol ViewModelOrderType {
    var input: Input!{get}
    var output: Output!{get}
    associatedtype Input
    associatedtype Output
}





/// 使用示例
//import RxSwift
//import RxCocoa
//class ExampleVM: ViewModelOrderType {
//    var input: Input!
//    var output: Output!
//    struct Input {
//        ///填写输入input
//        let exampleInput:AnyObserver<AnyObject>
//    }
//    struct Output {
//        ///填写输出output
//        let exampleOutput:Driver<AnyObject>
//    }
//    ///转换层
//    private var exampleInputSubject:ReplaySubject<AnyObject> = ReplaySubject<AnyObject>.create(bufferSize: 1)
//    init() {
//        ///开始转换 输入->输出
//        let exampleGreeting = exampleInputSubject.asObserver().flatMapLatest {[weak self] (model) -> Observable<AnyObject> in
//            return self!.exampleNetAction(withPrams: 1 as AnyObject)
//        }
//        /// 创建输入输出层
//        input=Input(exampleInput: exampleInputSubject.asObserver())
//        output=Output(exampleOutput: exampleGreeting.asDriver(onErrorJustReturn: 1 as AnyObject))
//    }
//
//    /// 网络请求
//    private func exampleNetAction(withPrams examplePrams:AnyObject) ->  Observable<AnyObject>{
//        return Observable<AnyObject>.create { (observer) -> Disposable in
//            /// 此处使用 网络工具层
//            observer.onNext(1 as AnyObject)
//            observer.onCompleted()
//            return Disposables.create {
//            }
//        }
//    }
//}

